package cn.itcast.service.impl;

import cn.itcast.dao.MemberFilesDao;
import cn.itcast.entity.PageResult;
import cn.itcast.entity.QueryPageBean;
import cn.itcast.pojo.Member;
import cn.itcast.service.MemberFilesService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class MemberFilesServiceImpl implements MemberFilesService {
    @Autowired
    private MemberFilesDao memberDao;


    /**
     * 新增会员项
     *
     * @param member
     */
    @Override
    public void add(Member member) {
        //设置时间
        member.setRegTime(new Date());
        //设置状态
        member.setStatus(0);
        memberDao.add(member);
    }


    /**
     * 分页查询会员数据
     *
     * @param queryPageBean
     * @return
     */
    @Override
    public PageResult pageQuery(QueryPageBean queryPageBean) {
        //开启分页查询
        PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        //根据条件分页查询检查项信息
        Page<Member> page = memberDao.selectByCondition(queryPageBean.getQueryString());
        //构建分页数据返回
        return new PageResult(page.getTotal(), page.getResult());
    }

    /**
     * 根据id查询会员项
     *
     * @param id
     * @return
     */
    @Override
    public Member findById(int id) {
        return memberDao.findById(id);
    }


    /**
     * 更新会员项数据
     *
     * @param member
     */
    @Override
    public void edit(Member member) {
        memberDao.update(member);
    }


    /**
     * 修改会员状态
     *
     * @param
     * @return
     */
    @Override
    public void editStstus(Integer id, Integer status) {
        memberDao.editStatus(id, status);
    }


}


